package com.hulk.dryad.manage.config;


import com.hulk.dryad.manage.jpush.JpushProperties;
import com.hulk.dryad.manage.jpush.template.JpushTemplate;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author hulk
 * jpush 自动配置类
 */
@Configuration
@RequiredArgsConstructor
@EnableConfigurationProperties({ JpushProperties.class })
@ConditionalOnProperty(name = "jpush.enable", havingValue = "true", matchIfMissing = false)
public class JpushConfig {



        private final JpushProperties properties;



        /**
         * 极光推送API辅助工具
         *
         * @return JPush实例
         */
        @Bean
        @ConditionalOnMissingBean(JpushTemplate.class)
        public JpushTemplate jpushTemplate() {
            final JpushTemplate push = new JpushTemplate(properties,false);
            push.init();
            return push;
        }



}
